Skip to content

Conversation

@finalbossqc
Copy link

Additions:

  • Added an implementation of breadth first search in GraphMatrix class.
  • Added an implementation of operator<< in GraphMatrix class.
  • Added a new example in Appledore/examples demonstrating bfs

}
}

friend std::ostream& operator<<(std::ostream& src, const GraphMatrix& other) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there a << operator in the class?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly for convenience. It allows for printing basic information about the graph using

std::cout << graph

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats a good approach.

But actually its not needed, the << operator overload is reserved for future to read graphs from a file, also user can print the graphs according to how they want, printing graphs on the console is not the concern of the library. 👍🏼

}
}

std::vector<EdgeType> bfs(size_t start, size_t maxDepth) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the start variable be of type VertexType? because user is passing in a vertex to start bfs from?

Suggested change
std::vector<EdgeType> bfs(size_t start, size_t maxDepth) {
std::vector<EdgeType> bfs(VertexType start, size_t maxDepth) {

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you're rights. I can make that change

@SharonIV0x86 SharonIV0x86 added feature addition Lable for a new Feature Addition Under Testing The PR is under testing by owner or maintainer. labels Jan 23, 2025
@SharonIV0x86
Copy link
Owner

SharonIV0x86 commented Jan 24, 2025

@finalbossqc

Your current implementation will not work with custom vertex and edge types.

There is a reason that as of now the library doesn't have its dfs and bfs implementations for graphs. The reason is that we are dealing with custom edges and vertices, where edges and vertices will always not be a integer or numeric values, but edges and vertices can be classes, structs, enums, even heavily templated types. And due to this the complexity sort of skyrockets. So there is a need of a solid mechanism to implement the algorithms which work for all types.

While i appreciate taking your interest in contributing to Appledore, the algorithms implementation such as dfs and bfs will require much time and testing to be implmented. If you'd like you can work on the following open issues, or if you'd like to continue working with your bfs pull requests you are free to do so, this was just a suggestion

@finalbossqc
Copy link
Author

Ok, I will work on writing some tests and making the implementation work independent of type. Any feedback from time to time is much appreciated

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 7, 2025

@SharonIV0x86 SharonIV0x86 added wontfix This will not be worked on and removed Under Testing The PR is under testing by owner or maintainer. labels Feb 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature addition Lable for a new Feature Addition wontfix This will not be worked on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants